'use strict';

const Controller = require('egg').Controller;

class InstructorController extends Controller {
    // // 查询获取数据用控制器——GET——/name?keywords=?&&.....
    async get_topic() {
        const { ctx } = this;
        const tea_id = ctx.query.tea_id;
        const keywords = ctx.query.keywords ? ctx.query.keywords : '';
        const pageIndex = ctx.query.pageIndex ? +ctx.query.pageIndex : 1;
        const pageSize = ctx.query.pageSize ? +ctx.query.pageSize : 5;
        console.log('keywords', keywords);
        const result = await ctx.service.topic.findTopicForTeacher(keywords, pageIndex, pageSize, tea_id);
        ctx.status = 200;
        ctx.body = result;
    }
    async get_topic_student() {
        const { ctx } = this;
        const teacher_id = ctx.query.teacher_id;
        const keywords = ctx.query.keywords ? ctx.query.keywords : '';
        const pageIndex = ctx.query.pageIndex ? +ctx.query.pageIndex : 1;
        const pageSize = ctx.query.pageSize ? +ctx.query.pageSize : 5;
        console.log('keywords', keywords);
        const result = await ctx.service.topic.findTopicStudentList(keywords, pageIndex, pageSize, teacher_id);
        ctx.status = 200;
        ctx.body = result;
    }
    async getStudentInfo(){
        const { ctx } = this;
        const stu_id = ctx.params.id;
        const stu_detail = await ctx.service.student.findById(stu_id);
        const stu_current_progress = stu_detail.progress;
        console.log('stu_current_progress:::::::::',stu_current_progress);
        // 需要学生的id以及当前阶段的编号
        // const files_Submitted_Current = await ctx.service.stufile.
        ctx.status = 200;
        ctx.body = stu_detail;
    }
}
module.exports = InstructorController;
